﻿/*
	Class				DisplayType
	
	Description		------
					
	History			1.00	7/12/07		Created
	
	To Do				Fix HitArea issue
*/

package tv.digitalfx
{
	import pete.tools.removeChildren;
	import tv.digitalfx.Screen;
	import flash.display.Sprite;
	import flash.text.*;
	
	public class DisplayType extends Sprite
	{
		public  var textField:TextField;
		private var _textFormat:TextFormat;
		private var _text:String;
		
		
		public function DisplayType ($font:Font, $color:uint)
		{
			_textFormat					= new TextFormat ();
			_textFormat.font				= $font.fontName;
			_textFormat.align				= TextFormatAlign.LEFT;
			_textFormat.size				= 13;
			_textFormat.letterSpacing		= 2;
			
			this.textField					= new TextField ();
			this.textField.defaultTextFormat	= _textFormat;
			this.textField.gridFitType		= GridFitType.SUBPIXEL;
			this.textField.embedFonts		= true;
			this.textField.textColor			= $color;
			this.textField.autoSize			= TextFieldAutoSize.LEFT;
			this.textField.selectable		= false;
		}
		
		
		public function get text ():String
		{
			return 						(_text);
		}
		
		
		public function set text ($text:String):void
		{
			_text 						= $text;
			this.textField.text				= $text;
			
			this.render ();
		}
		
		
		public function render ():void
		{
			var textScreen:Screen			= new Screen (this.textField, 2);
			removeChildren		(this);
			addChild						(textScreen);
		}
		
		
	}
}